﻿Imports VN.INS.BL.BC
Imports System.Data
Imports System.Web
Imports System.IO

Partial Class devida_f_monitoreo
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ibEliminar.Attributes.Add("onClick", "return confirm('Seguro que desea eliminar el Plan de Trabajo seleccionado?')")
        If (Not (Page.IsPostBack)) Then
            'Validacion de sesiones
            Sesion(Session("Nombre"))            
            Sesion(Session("Persona"))
            Sesion(Session("perfil"))
            Sesion(Session("PPER"))
            ViewState("Persona") = Session("Persona")
            ViewState("Perfil") = Session("perfil")
            ViewState("PPER") = Session("PPER")
            'carga de titulo y combos
            lblTitulo.Text = "Formato 01 - Plan de trabajo mensual"
            ListaMonitoreador()
            ListaPeriodo()
            ddl_PERIODO.SelectedValue = "all"
            'Si el usuario es...
            If ViewState("Perfil") = "MO" Then 'monitoreador
                ddl_Monitoreador.Enabled = False
                ddl_pper.Enabled = False
                ibAgregar.Visible = True
                ibModificar.Visible = True
                ibEliminar.Visible = True
                ibAprobar.Visible = False
                ibConsultar.Visible = True
                ddl_Monitoreador.SelectedValue = ViewState("Persona")
                ListaPPER()
                ddl_pper.SelectedValue = ViewState("PPER")
                CargarGrilla()
            ElseIf ViewState("Perfil") = "AD" Then 'administrador
                ddl_Monitoreador.Enabled = True
                ddl_pper.Enabled = True
                ibAgregar.Visible = True
                ibModificar.Visible = True
                ibEliminar.Visible = True
                ibAprobar.Visible = False
                ibConsultar.Visible = True
                ddl_Monitoreador.SelectedValue = ""
                ListaPPER()
                ddl_pper.SelectedValue = ""
                CargarGrillaAdmin(ddl_Monitoreador.SelectedValue.ToString, ddl_pper.SelectedValue.ToString, ddl_PERIODO.SelectedValue.ToString)
            ElseIf ViewState("Perfil") = "RE" Then 'Consulta
                ddl_Monitoreador.Enabled = True
                ddl_pper.Enabled = True
                ibAgregar.Visible = False
                ibModificar.Visible = False
                ibEliminar.Visible = False
                ibAprobar.Visible = False
                ibConsultar.Visible = True
                ddl_Monitoreador.SelectedValue = ""
                ListaPPER()
                ddl_pper.SelectedValue = ""
                CargarGrillaAdmin(ddl_Monitoreador.SelectedValue.ToString, ddl_pper.SelectedValue.ToString, ddl_PERIODO.SelectedValue.ToString)

            ElseIf ViewState("Perfil") = "EP" Then 'Especialista

                '   "PER-0026"'G Marin (PTCD)...
                '   "PER-0046"' J Vargas (PTCD)...
                '   "PER-0022"' E Julca (PIRDAIS)
                If (ViewState("Persona") = "PER-0026") Or (ViewState("Persona") = "PER-0046") Or (ViewState("Persona") = "PER-0075") Or (ViewState("Persona") = "PER-0022") Then
                    ddl_pper.Enabled = False
                    ibAgregar.Visible = False
                    ibModificar.Visible = False
                    ibEliminar.Visible = False
                    ibAprobar.Visible = True 'By Tigrito (04/06/2013): Habilita el botón de aprobación
                    ibConsultar.Visible = True
                    ddl_Monitoreador.SelectedValue = ""
                    ListaPPER()
                    ddl_pper.SelectedValue = ViewState("PPER")
                    'CargarGrilla()
                    CargarGrillaEsp(ViewState("Persona"), ddl_Monitoreador.SelectedValue.ToString, ddl_pper.SelectedValue.ToString, ddl_PERIODO.SelectedValue.ToString, Session("Año"))
                Else 'By Tigrito (30/05/2013): Para el resto de especialistas
                    ddl_pper.Enabled = False
                    ibAgregar.Visible = False
                    ibModificar.Visible = False
                    ibEliminar.Visible = False
                    ibAprobar.Visible = False
                    ibConsultar.Visible = True
                    ddl_Monitoreador.SelectedValue = ""
                    ListaPPER()
                    ddl_pper.SelectedValue = ViewState("PPER")
                    'CargarGrilla()
                    CargarGrillaEsp(ViewState("Persona"), ddl_Monitoreador.SelectedValue.ToString, ddl_pper.SelectedValue.ToString, ddl_PERIODO.SelectedValue.ToString, Session("Año"))
                End If

            Else        'Otros perfiles
                ddl_pper.Enabled = False
                ibAgregar.Visible = False
                ibModificar.Visible = False
                ibEliminar.Visible = False
                ibAprobar.Visible = True
                ibConsultar.Visible = True
                ddl_Monitoreador.SelectedValue = ""
                ListaPPER()
                ddl_pper.SelectedValue = ViewState("PPER")
                CargarGrilla()
            End If
        End If
    End Sub

    'Carga lista de trabajos sin filtros
    Public Sub CargarGrilla()
        Dim objusuario As PPERBC
        Dim objData As DataTable
        objusuario = New PPERBC
        objData = New DataTable
        objData = objusuario.ListaTrabajos(ViewState("Persona"), Session("Año"))
        gv_impresion.DataSource = objData
        gv_impresion.DataBind()
        gv_impresion.SelectedIndex = -1
        gv_doc.DataSource = objData
        gv_doc.DataBind()
    End Sub

    'Carga lista de trabajos con filtros
    Public Sub CargarGrilla(ByVal user As String, ByVal pper As String, ByVal periodo As String)
        Dim objusuario As PPERBC
        Dim objData As DataTable
        objusuario = New PPERBC
        objData = New DataTable
        objData = objusuario.ListaTrabajos(ViewState("Persona"), user, pper, periodo, Session("Año"))
        gv_impresion.DataSource = objData
        gv_impresion.DataBind()
        gv_doc.DataSource = objData
        gv_doc.DataBind()
    End Sub

    'Carga Grilla Especialista
    Public Sub CargarGrillaEsp(ByVal strCodEsp As String, ByVal srtCodMonit As String, ByVal srtCodPper As String, ByVal srtCodPeriodo As String, ByVal srtCodAnhio As String)
        Dim objusuario As PPERBC
        Dim objData As DataTable
        objusuario = New PPERBC
        objData = New DataTable
        objData = objusuario.ListaTrabajosEsp(strCodEsp, srtCodMonit, srtCodPper, srtCodPeriodo, srtCodAnhio)
        gv_impresion.DataSource = objData
        gv_impresion.DataBind()
        gv_doc.DataSource = objData
        gv_doc.DataBind()
    End Sub

    'Carga lista de trabajos administrador
    Public Sub CargarGrillaAdmin(ByVal user As String, ByVal pper As String, ByVal periodo As String)
        Dim objusuario As PPERBC
        Dim objData As DataTable
        objusuario = New PPERBC
        objData = New DataTable
        objData = objusuario.ListaTabajosAdministrador(user, pper, periodo, Session("Año"))
        gv_impresion.DataSource = objData
        gv_impresion.DataBind()
        gv_doc.DataSource = objData
        gv_doc.DataBind()
    End Sub

    Public Sub ListaPPER()
        Dim objPPER As PPERBC
        Dim objData As DataTable
        objPPER = New PPERBC
        objData = New DataTable
        objData = objPPER.ListaPPER(ddl_Monitoreador.SelectedValue.ToString)
        Dim drusuariorow As DataRow = objData.NewRow()
        drusuariorow("DESCRIPCION") = "--Seleccione--"
        drusuariorow("PPER") = ""
        objData.Rows.Add(drusuariorow)
        ddl_pper.DataSource = objData
        ddl_pper.DataTextField = "DESCRIPCION"
        ddl_pper.DataValueField = "PPER"
        ddl_pper.DataBind()
    End Sub

    Public Sub ListaMonitoreador()
        Dim objusuario As UsuarioBC
        Dim objData As DataTable
        Dim user As String
        objusuario = New UsuarioBC
        objData = New DataTable
        If ViewState("Perfil") = "AD" Or ViewState("Perfil") = "RE" Then
            user = ""
        Else
            user = ViewState("Persona")
        End If
        objData = objusuario.ListaUsuarioperfil("MO", user)
        Dim drusuariorow As DataRow = objData.NewRow()
        drusuariorow("NOMBRE") = "--Seleccione--"
        drusuariorow("PERSONA") = ""
        objData.Rows.Add(drusuariorow)
        ddl_Monitoreador.DataSource = objData
        ddl_Monitoreador.DataTextField = "NOMBRE"
        ddl_Monitoreador.DataValueField = "PERSONA"
        ddl_Monitoreador.DataBind()
        ddl_Monitoreador.SelectedValue = ""
    End Sub

    Public Sub ListaPeriodo()
        Dim objgeneralbc As GeneralBC = New GeneralBC
        Dim objData As DataTable
        If ViewState("Perfil") = "AD" Or ViewState("Perfil") = "RE" Then
            objData = objgeneralbc.ListaMes("", "", Session("Año"))
        Else
            objData = objgeneralbc.ListaMes(Session("Persona").ToString, "", Session("Año"))
        End If
        Dim drusuariorow As DataRow = objData.NewRow()
        drusuariorow("DESCRIPCION") = "--Seleccione--"
        drusuariorow("PERIODO") = "all"
        objData.Rows.Add(drusuariorow)
        ddl_PERIODO.DataSource = objData
        ddl_PERIODO.DataTextField = "DESCRIPCION"
        ddl_PERIODO.DataValueField = "PERIODO"
        ddl_PERIODO.DataBind()
    End Sub

    Protected Sub btn_busca_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btn_busca.Click
        If ViewState("Perfil") = "AD" Or ViewState("Perfil") = "RE" Then  'si es administrador            
            CargarGrillaAdmin(ddl_Monitoreador.SelectedValue.ToString, ddl_pper.SelectedValue.ToString, ddl_PERIODO.SelectedValue.ToString)
        ElseIf ViewState("Perfil") = "EP" Then
            'Carga la grilla con filtros para el Especialista
            CargarGrillaEsp(ViewState("Persona"), ddl_Monitoreador.SelectedValue.ToString, ddl_pper.SelectedValue.ToString, ddl_PERIODO.SelectedValue.ToString, Session("Año"))
        Else 'Otros perfiles
            'Carga la grilla con filtros para otros perfiles
            CargarGrilla(ddl_Monitoreador.SelectedValue.ToString, ddl_pper.SelectedValue.ToString, ddl_PERIODO.SelectedValue.ToString)
        End If
    End Sub

    Protected Sub ibAgregar_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ibAgregar.Click
        'redirecciona a plan de trabajo
        Response.Redirect("~/Devida/PlanTrabajo.aspx?Nuevo=1" & "&Persona=" & ViewState("VSPersona"))        
    End Sub

    Protected Sub gv_impresion_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv_impresion.RowDataBound
        ' FORMATEA ROWS
        If e.Row.RowType = DataControlRowType.DataRow Then
            ' ASIGNA EVENTOS
            e.Row.Attributes.Add("OnMouseOver", "Resaltar_On(this);")
            e.Row.Attributes.Add("OnMouseOut", "Resaltar_Off(this);")
            e.Row.Attributes("OnClick") = Page.ClientScript.GetPostBackClientHyperlink(Me.gv_impresion, "Select$" + e.Row.RowIndex.ToString)
      
            Dim estado As HiddenField = CType(e.Row.FindControl("hfEstado"), HiddenField)

            Select Case e.Row.Cells(5).Text.ToString.Substring(0, e.Row.Cells(5).Text.Length - 5)
                Case "ENERO"
                    e.Row.Cells(5).BackColor = Drawing.Color.Navy
                    e.Row.Cells(5).ForeColor = Drawing.Color.White
                Case "FEBRERO"
                    e.Row.Cells(5).BackColor = Drawing.Color.MintCream
                    e.Row.Cells(5).ForeColor = Drawing.Color.Blue
                Case "MARZO"
                    e.Row.Cells(5).BackColor = Drawing.Color.DodgerBlue
                    e.Row.Cells(5).ForeColor = Drawing.Color.White
                Case "ABRIL"
                    e.Row.Cells(5).BackColor = Drawing.Color.MidnightBlue
                    e.Row.Cells(5).ForeColor = Drawing.Color.White
                Case "MAYO"
                    e.Row.Cells(5).BackColor = Drawing.Color.HotPink
                    e.Row.Cells(5).ForeColor = Drawing.Color.Black
                Case "JUNIO"
                    e.Row.Cells(5).BackColor = Drawing.Color.PaleGreen
                    e.Row.Cells(5).ForeColor = Drawing.Color.Black
                Case "JULIO"
                    e.Row.Cells(5).BackColor = Drawing.Color.Gainsboro
                    e.Row.Cells(5).ForeColor = Drawing.Color.Black
                Case "AGOSTO"
                    e.Row.Cells(5).BackColor = Drawing.Color.MediumPurple
                    e.Row.Cells(5).ForeColor = Drawing.Color.White
                Case "SEPTIEMBRE"
                    e.Row.Cells(5).BackColor = Drawing.Color.Turquoise
                    e.Row.Cells(5).ForeColor = Drawing.Color.Black
                Case "OCTUBRE"
                    e.Row.Cells(5).BackColor = Drawing.Color.Yellow
                    e.Row.Cells(5).ForeColor = Drawing.Color.Black
                Case "NOVIEMBRE"
                    e.Row.Cells(5).BackColor = Drawing.Color.DodgerBlue
                    e.Row.Cells(5).ForeColor = Drawing.Color.White
                Case "DICIEMBRE"
                    e.Row.Cells(5).Style("background-color") = "#ffcc66"
                    'e.Row.Cells(5).ForeColor = Drawing.Color.Black
                Case Else
            End Select

            'nombrado de estado segun codigo
            If Not (estado Is Nothing) Then
                If estado.Value = "1" Then
                    e.Row.Cells(6).Text = "REGISTRADO"
                End If
                If estado.Value = "2" Then
                    e.Row.Cells(6).Text = "CONFORME"
                End If
                If estado.Value = "3" Then
                    e.Row.Cells(6).Text = "OBSERVADO"
                End If
            End If

            If (e.Row.Cells(6).Text <> "&nbsp;") And (e.Row.Cells(7).Text = "&nbsp;") Then
                e.Row.Cells(7).Text = "FALTA APROBAR"
                e.Row.Cells(7).BackColor = Drawing.Color.LightPink
                e.Row.Cells(7).ForeColor = Drawing.Color.Purple
                'e.Row.Cells(8).ForeColor = Drawing.Color.FromName("#9c2d75")
            End If
        End If
    End Sub

    'salir
    Protected Sub ibSalir_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ibSalir.Click
        Response.Redirect("~/Devida/Inicio.aspx")
    End Sub

    Protected Sub ibEliminar_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ibEliminar.Click
        If gv_impresion.SelectedIndex = -1 Then 'sin seleccion
            alerta.Mostrar_Alerta("Aviso", "Debe seleccionar un registro")
        Else                                    'con seleccion
            If ViewState("VSEstado").ToString = "2" Then    'plan aprobado
                alerta.Mostrar_Alerta("Aviso", "No se puede eliminar un PLan de Trabajo Aprobado")
            Else                                            'plan sin aprobar
                Try
                    Dim objMonitoreo As New MONITOREOBC
                    'Eliminar plan
                    objMonitoreo.EliminarPlanTrabajo(CInt(ViewState("VSCodigo")))
                    'cargar grilla segun perfil
                    If ViewState("Perfil") = "AD" Then
                        CargarGrillaAdmin(ddl_Monitoreador.SelectedValue.ToString, ddl_pper.SelectedValue.ToString, ddl_PERIODO.SelectedValue.ToString)
                    Else
                        CargarGrilla(ddl_Monitoreador.SelectedValue.ToString, ddl_pper.SelectedValue.ToString, ddl_PERIODO.SelectedValue.ToString)
                    End If
                Catch ex As Exception
                    alerta.Mostrar_Alerta("Aviso", "No se pudo eliminar PLan de Trabajo")
                End Try
            End If
        End If
    End Sub

    Protected Sub gv_impresion_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles gv_impresion.SelectedIndexChanged
        Dim htxtCodigo As HiddenField = CType(gv_impresion.SelectedRow.FindControl("hfCodigo"), HiddenField)
        Dim htxtPeriodo As HiddenField = CType(gv_impresion.SelectedRow.FindControl("hfPeriodo"), HiddenField)
        Dim htxtEstado As HiddenField = CType(gv_impresion.SelectedRow.FindControl("hfEstado"), HiddenField)
        Dim htxtPersona As HiddenField = CType(gv_impresion.SelectedRow.FindControl("hfPersona"), HiddenField)
        Dim htxtPper As HiddenField = CType(gv_impresion.SelectedRow.FindControl("hfPPER"), HiddenField)
        'Captura de variables al seleccionar registro
        Try
            If Not htxtCodigo Is Nothing Then
                ViewState("VSCodigo") = htxtCodigo.Value.ToString
            End If
            If Not htxtPeriodo Is Nothing Then
                ViewState("VSPeriodo") = htxtPeriodo.Value.ToString
            End If
            If Not htxtEstado Is Nothing Then
                ViewState("VSEstado") = htxtEstado.Value.ToString
            End If
            If Not htxtPersona Is Nothing Then
                ViewState("VSPersona") = htxtPersona.Value.ToString
            End If
            If Not htxtPper Is Nothing Then
                ViewState("VSPPER") = htxtPper.Value.ToString
            End If
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Protected Sub ibModificar_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ibModificar.Click
        'si existe registro seleccionado, se redirecciona a edicion de plan de trabajo
        If gv_impresion.SelectedIndex = -1 Then
            alerta.Mostrar_Alerta("Aviso", "Debe seleccionar un registro")
        Else
            Response.Redirect("~/Devida/PlanTrabajo.aspx?Nuevo=0&Codigo=" & ViewState("VSCodigo") & "&Periodo=" & ViewState("VSPeriodo") & "&Estado=" & ViewState("VSEstado") & "&Persona=" & ViewState("VSPersona"))
        End If
    End Sub

    Protected Sub ibAprobar_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ibAprobar.Click
        'si existe registro seleccionado, se redirecciona a aprobacion de plan de trabajo
        If gv_impresion.SelectedIndex = -1 Then
            alerta.Mostrar_Alerta("Aviso", "Debe seleccionar un registro")
        Else
            Response.Redirect("~/Devida/PlanTrabajo.aspx?Nuevo=2&Codigo=" & ViewState("VSCodigo") & "&Periodo=" & ViewState("VSPeriodo") & "&Estado=" & ViewState("VSEstado") & "&Persona=" & ViewState("VSPersona") & "&PPER=" & ViewState("VSPPER"))
        End If
    End Sub

    Protected Sub ddl_Monitoreador_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddl_Monitoreador.SelectedIndexChanged
        'filtra grilla segun perfil
        ListaPPER()

        If ViewState("Perfil") = "AD" Or ViewState("Perfil") = "RE" Then  'si es administrador            
            CargarGrillaAdmin(ddl_Monitoreador.SelectedValue.ToString, ddl_pper.SelectedValue.ToString, ddl_PERIODO.SelectedValue.ToString)
        ElseIf ViewState("Perfil") = "EP" Then
            'Carga la grilla con filtros para el Especialista
            CargarGrillaEsp(ViewState("Persona"), ddl_Monitoreador.SelectedValue.ToString, ddl_pper.SelectedValue.ToString, ddl_PERIODO.SelectedValue.ToString, Session("Año"))
        Else 'Otros perfiles
            'Carga la grilla con filtros para otros perfiles
            CargarGrilla(ddl_Monitoreador.SelectedValue.ToString, ddl_pper.SelectedValue.ToString, ddl_PERIODO.SelectedValue.ToString)
        End If

    End Sub

    Protected Sub ddl_pper_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddl_pper.SelectedIndexChanged
        'filtra grilla segun perfil
        If ViewState("Perfil") = "AD" Or ViewState("Perfil") = "RE" Then
            CargarGrillaAdmin(ddl_Monitoreador.SelectedValue.ToString, ddl_pper.SelectedValue.ToString, ddl_PERIODO.SelectedValue.ToString)
        Else
            CargarGrilla(ddl_Monitoreador.SelectedValue.ToString, ddl_pper.SelectedValue.ToString, ddl_PERIODO.SelectedValue.ToString)
        End If
    End Sub

    Protected Sub ddl_PERIODO_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddl_PERIODO.SelectedIndexChanged
        'filtra grilla segun perfil

        If ViewState("Perfil") = "AD" Or ViewState("Perfil") = "RE" Then  'si es administrador            
            CargarGrillaAdmin(ddl_Monitoreador.SelectedValue.ToString, ddl_pper.SelectedValue.ToString, ddl_PERIODO.SelectedValue.ToString)
        ElseIf ViewState("Perfil") = "EP" Then
            'Carga la grilla con filtros para el Especialista
            CargarGrillaEsp(ViewState("Persona"), ddl_Monitoreador.SelectedValue.ToString, ddl_pper.SelectedValue.ToString, ddl_PERIODO.SelectedValue.ToString, Session("Año"))
        Else 'Otros perfiles
            'Carga la grilla con filtros para otros perfiles
            CargarGrilla(ddl_Monitoreador.SelectedValue.ToString, ddl_pper.SelectedValue.ToString, ddl_PERIODO.SelectedValue.ToString)
        End If

    End Sub

    Protected Sub ibExportar_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ibExportar.Click
        ExportarGrilla(gv_doc)
    End Sub

    Private Sub ExportarGrilla(ByVal grilla As GridView)
        Dim sb As StringBuilder = New StringBuilder()
        Dim sw As StringWriter = New StringWriter(sb)
        Dim htw As HtmlTextWriter = New HtmlTextWriter(sw)
        Dim pagina As Page = New Page
        'CREAR TITULO
        Dim gvtitle As New Table
        Dim titulo1 As New TableCell()
        titulo1.RowSpan = 1
        titulo1.ColumnSpan = 6
        titulo1.Text = "LISTA DE PLANES DE TRABAJO"
        titulo1.Font.Name = "Calibri"
        titulo1.Font.Size = 12
        titulo1.Font.Bold = True
        titulo1.BackColor = Drawing.Color.White
        titulo1.HorizontalAlign = HorizontalAlign.Center
        titulo1.VerticalAlign = VerticalAlign.Middle
        Dim headertitulo1 As New TableRow()
        headertitulo1.Cells.Add(titulo1)
        gvtitle.Rows.AddAt(0, headertitulo1)
        '------------
        Dim form = New HtmlForm
        pagina.EnableEventValidation = False
        pagina.DesignerInitialize()
        pagina.Controls.Add(form)
        form.Controls.Add(gvtitle)
        form.Controls.Add(grilla)
        pagina.RenderControl(htw)
        Response.Clear()
        Response.Buffer = True
        Response.ContentType = "application/vnd.ms-excel"
        Response.AddHeader("Content-Disposition", "attachment;filename=Lista_POA.xls")
        Response.Charset = "UTF-8"
        Response.ContentEncoding = Encoding.Default
        Response.Write(sb.ToString())
        Response.End()
    End Sub

    Protected Sub ibConsultar_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ibConsultar.Click
        'si existe registro seleccionado, se redirecciona a consulta de plan de trabajo
        If gv_impresion.SelectedIndex = -1 Then
            alerta.Mostrar_Alerta("Aviso", "Debe seleccionar un registro")
        Else
            Response.Redirect("~/Devida/PlanTrabajo.aspx?Nuevo=3&Codigo=" & ViewState("VSCodigo") & "&Periodo=" & ViewState("VSPeriodo") & "&Estado=" & ViewState("VSEstado") & "&Persona=" & ViewState("VSPersona") & "&PPER=" & ViewState("VSPPER"))
        End If
    End Sub

    'perdida de sesion
    Public Sub Sesion(ByVal session As Object)
        Dim lost As String
        lost = ""
        If (session Is Nothing) Then lost = "1" Else lost = "0"
        If lost = "1" Then
            Response.Redirect("s_login.aspx?Error=1")
        End If
    End Sub

End Class